package translated;

import java.util.List;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.jet.util.*;

public class EpTreeFactoryGen
{
  protected static String nl;
  public static synchronized EpTreeFactoryGen create(String lineSeparator)
  {
    nl = lineSeparator;
    EpTreeFactoryGen result = new EpTreeFactoryGen();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "/**" + NL + " * Copyright (c) Software Institute of PKU" + NL + " * All rights reserved. " + NL + " * This program and the accompanying materials" + NL + " * are made available under the terms of the Eclipse Public License v1.0" + NL + " * which accompanies this distribution, and is available at" + NL + " * http://www.eclipse.org/legal/epl-v10.html" + NL + " *" + NL + " */" + NL + "package ";
  protected final String TEXT_2 = ";" + NL + "" + NL + "import org.eclipse.gef.EditPart;" + NL + "" + NL + "import edu.pku.sei.modeler.edit.parts.AbstractTreeEditPartFactory;" + NL + "import edu.pku.sei.modeler.model.core.MetaElement;" + NL + "import edu.pku.sei.modeler.model.structure.MetaShapeElement;";
  protected final String TEXT_3 = NL + "import ";
  protected final String TEXT_4 = ".*;";
  protected final String TEXT_5 = NL + NL + "/**" + NL + " * @generated" + NL + " *" + NL + " */" + NL + "public class ModelTreeEditpartFactory extends AbstractTreeEditPartFactory{" + NL + "    public EditPart createEditPart(MetaShapeElement shape)" + NL + "\t{" + NL + "\t\tEditPart part = null;" + NL + "\t\tMetaElement content = shape.getModelElement();" + NL + "\t\tif (false){" + NL + "\t\t\tpart = null;" + NL + "\t\t}" + NL + "\t\t";
  protected final String TEXT_6 = NL + "\t\telse if(content instanceof ";
  protected final String TEXT_7 = ") {" + NL + "\t\t\tpart = new ";
  protected final String TEXT_8 = "TreeEditpart(shape);" + NL + "\t\t}" + NL + "\t\t";
  protected final String TEXT_9 = NL + "\t\telse {" + NL + "\t\t\tpart = super.createEditPart(shape);" + NL + "\t\t}" + NL + "\t\treturn part;" + NL + "\t}" + NL + "}";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
     List modelList = (List) argument; 
    stringBuffer.append(TEXT_1);
    stringBuffer.append(ModelerConstants.pkgBase + "." + ModelerConstants.editpartBase);
    stringBuffer.append(TEXT_2);
    
	List pkgPaths = PackageRetriever.pkgPathList;
	for(int i=0; i<pkgPaths.size(); i++) {

    stringBuffer.append(TEXT_3);
    stringBuffer.append(pkgPaths.get(i));
    stringBuffer.append(TEXT_4);
    
	}

    stringBuffer.append(TEXT_5);
    
		for(int i=0; i<modelList.size(); i++) {
			MetaClass cls = (MetaClass)modelList.get(i);
		
    stringBuffer.append(TEXT_6);
    stringBuffer.append(cls.getName());
    stringBuffer.append(TEXT_7);
    stringBuffer.append(cls.getName());
    stringBuffer.append(TEXT_8);
    
		}
		
    stringBuffer.append(TEXT_9);
    return stringBuffer.toString();
  }
}
